import { Map } from "immutable"

import * as actionType from "./constants"
const defaultState = Map({
    currentSong: {},
    playList: [],
    currentSongIndex: 0,
    sequence: 0,
    lyric: [],
    lyricIndex: 0,
    isBottomMusic: true,
    simiPlaylist: [],
    simiSongs: [],
})


function reducer(state = defaultState, action) {
    switch (action.type) {
        case actionType.CHANGE_SONG:
            return state.set("currentSong", action.currentSong)
        case actionType.CHANGE_CURRENT_SONG_INDEX:
            return state.set("currentSongIndex", action.index)
        case actionType.CHANGE_PLAYER_LIST:
            return state.set("playList", action.playList)
        case actionType.CHANGE_SEQUENCE:
            return state.set("sequence", action.sequence)
        case actionType.CHANGE_LYRIC:
            return state.set("lyric", action.lyric)
        case actionType.CHANGE_CURRENT_LYRIC_INDEX:
            return state.set("lyricIndex", action.lyricIndex)
        case actionType.CHANGE_ISBOTTOM_MUSIC:
            return state.set("isBottomMusic", action.isBottomMusic)
        case actionType.CHANGE_SIMI_PLAYLIST:
            return state.set("simiPlaylist", action.simiPlaylist);
        case actionType.CHANGE_SIMI_SONGS:
            return state.set("simiSongs", action.simiSongs);
        default:
            return state
    }
}


export default reducer